﻿namespace NJQuery {
	using System;
	using System.Web.UI;
	using System.IO;
	using System.Text;

	/// <summary>
	/// Serves as sub-control group to effectively give a control multiple child control collections.
	/// </summary>
	public class GroupControlContainer : Control {


		#region Fields

		private Control owner;

		#endregion


		#region Constructors

		/// <summary>
		/// Creates a new instance of the <see cref="GroupControlContainer"/> class.
		/// </summary>
		/// <param name="owner">The <see cref="Control"/> object that the container belongs to.</param>
		public GroupControlContainer(Control owner) {
			if(owner == null) throw new ArgumentNullException("owner");

			this.owner = owner;
		}

		#endregion


		#region Properties

		/// <summary>
		/// Gets the <see cref="Control"/> object that the container belongs to.
		/// </summary>
		public virtual Control Owner {
			get { return owner; }
		}

		#endregion


		#region Methods

		public string RenderHtml() {
			StringBuilder stringBuilder = new StringBuilder();
			using(StringWriter stringWriter = new StringWriter(stringBuilder))
			using(HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter)) {
				RenderChildren(htmlTextWriter);
			}
			return stringBuilder.ToString();
		}

		#endregion


	}

}